﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Tssipl.PaymentAdapter.Core;
using Tssipl.PaymentAdapter.MessageFormat.Sfms;
namespace Tssipl.PaymentAdapter.MessageEntity.Sfms.Neft
{
     
    public class NeftN90Specification : Tssipl.PaymentAdapter.MessageEntity.Sfms.SfmsMessageEntityBase
    {
        public SfmsBlock4 block4 { get; set; }

        public string TRN { get; set; }//16x //M
        public string AcknowledgementIndicator  { get; set; }//1!x  //M
        public string BatchReleaseTime { get; set; }//6!n
        public string ReasonCode { get; set; }//3!x  //M
       

        public NeftN90Specification(MessageParseResults results)
            : base(results)
        {
            SfmsMessage message = (SfmsMessage)results.getMessage();
            SfmsBlock4 block4 = message.getBlock4();
            this.TRN = block4.getField("2020").Trim();

            this.AcknowledgementIndicator = block4.getField("6450");
            this.BatchReleaseTime = block4.getField("3525");
            this.ReasonCode = block4.getField("6346");

            
        }
        new public string Build()
        {
            block4 = new SfmsBlock4();

            // this.TRN = block4.getField("2020").Trim();
            block4.Fields.Add(new Field("2020", this.TRN));

            //this.AcknowledgementIndicator = block4.getField("6450");
            if (string.IsNullOrEmpty(this.AcknowledgementIndicator) == false) block4.Fields.Add(new Field("AcknowledgementIndicator", this.AcknowledgementIndicator));
            //this.BatchReleaseTime = block4.getField("3525");
            if (string.IsNullOrEmpty(this.BatchReleaseTime) == false) block4.Fields.Add(new Field("BatchReleaseTime", this.BatchReleaseTime));
            //this.ReasonCode = block4.getField("6346");
            if (string.IsNullOrEmpty(this.ReasonCode) == false) block4.Fields.Add(new Field("6346", this.ReasonCode));
            
            return base.Build() + block4.getFormattedBlock();
        }
    }
}
